Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new regex to properly match/parse channel topics. #3111

Merged
merged 3 commits into from
Nov 19, 2021

Conversation

Jerrie-Aries
Copy link
Contributor

About this PR:

  • New regex in core/utils.py.
  • Add a parse_channel_topic function that uses the new regex to parse the channel topic and return a tuple of 'title', 'user ID', and 'other recipients IDs'.
  • Remove couple of old regexes as they're no longer used.

With these new regex and methods, it would be easier to check and match the recipient ID.

Currently, in core/thread.py, line 1243:

channel = discord.utils.find(
                lambda x: str(recipient_id) in x.topic if x.topic else False,
                self.bot.modmail_guild.text_channels,
            )

..the bot just checks if the user ID is in the channel topic, regardless the string format. This PR solves that.

Please check.

Copy link
Collaborator

@Taaku18 Taaku18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems to be in order to me (please resolve the comment above), but I'm not the most familiar with group chats functionalities so it's best for 4jr to review it as well.

Also, if possible, would you be able to implement a "Bot ID: xxxxx" section into the topics and have it checked when finding the channel by topic along with this PR since it's somewhat related?

@Jerrie-Aries
Copy link
Contributor Author

Thanks for the review. The suggested changes (regex) have been added.

Copy link
Collaborator

@fourjr fourjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fourjr fourjr added the staged Staged for next version label Nov 19, 2021
@fourjr fourjr merged commit 4eca273 into modmail-dev:development Nov 19, 2021
@Jerrie-Aries Jerrie-Aries deleted the topic-regex branch November 21, 2021 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
staged Staged for next version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Modmail thinks a channel is a thread if a user ID is found within the topics
3 participants